package com.hitrust.gs.dao;

import java.util.ArrayList;

import com.hitrust.gs.bean.GSUserBean;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.lib.db.GSBaseDAO;
import com.hitrust.gs.util.exception.GSException;

public class GSUserDAO extends GSBaseDAO {
	
	public ArrayList queryByWarehouseCode(String warehouseCode) throws GSException{
		ArrayList tList = null;
        StringBuffer tSql = new StringBuffer("select * from t_user where warehouse_code like ?");
        Object[] tObj = {warehouseCode+"%"};
        GSLogWriter.debug(this,tSql.toString());
        try {
        	tList = this.executeQuery(new GSUserBean(), tSql.toString(), tObj);
		} catch (Exception e) {
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19999,GSException.E19999_MSG);
		}
        return tList;
	}
	public GSUserBean queryById(String id) throws GSException{
		ArrayList tList = null;
        StringBuffer tSql = new StringBuffer("select * from t_user where id =?");
        Object[] tObj = {id};
        GSLogWriter.debug(this,tSql.toString());
        try {
        	tList = this.executeQuery(new GSUserBean(), tSql.toString(), tObj);
        	if(tList!=null&&tList.size()>0){
        		return (GSUserBean)tList.get(0);
        	}
		} catch (Exception e) {
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19999,GSException.E19999_MSG);
		}
        return null;
	}
}
